package com.jack.leetcode.eachproblem_2020;

import java.util.Arrays;

/**
 * Created by zhang_j on 2020/11/23
 */
public class 用最少数量的箭引爆气球 {

    public static int findMinArrowShots(int[][] points) {
        if(points.length == 0){
            return 0;
        }
        Arrays.sort(points, (a, b) -> {
            return a[1] - b[1];
        });

        int target = points[0][1], result = 1;
        for(int i = 1;i < points.length;i++){
            if(target <= points[i][1] && target >= points[i][0]){

            }else{
                result++;
                target = points[i][1];
            }
        }
        return result;
    }

    public static void main(String[] args) {
        int[][] points = {{10,16},{2,8},{1,6},{7,12}};
        System.out.println(findMinArrowShots(points));
        int[][] a = {{3,9},{7,12},{3,8},{6,8},{9,10},{2,9},{0,9},{3,9},{0,6},{2,8}};
        System.out.println(findMinArrowShots(a));
    }
}
